/////////////////////////////////////////////////////////////////////////////
// Name:        mdi.h
// Purpose:     Bts GUI apps
// Author:      ray1944
// Modified by:
// Created:     01/14/2012
/////////////////////////////////////////////////////////////////////////////

#include "wx/toolbar.h"
#include "wx/intl.h"
#define MAX_DURATION_DAYS    31

// Define a new application
class BtsApp : public wxApp
{
public:
    bool OnInit();
    int OnExit();
    wxLocale * GetLocale() const
    {
        return m_locale;
    }
    void  SetLocale(wxLocale * newlocale)
    {
        if (NULL != newlocale)
        {
            if (NULL != m_locale)
            {
                delete m_locale;
                m_locale = NULL;
            }
            m_locale = newlocale;
        }
    }
private:
    void InitMenu();
    wxLocale * m_locale;
};

// Define a new frame
class MainFrame : public wxMDIParentFrame
{
public:
    wxTextCtrl * m_textWindow;

    MainFrame(
        wxWindow *parent, 
        const wxWindowID id, 
        const wxString& title,
        const wxPoint& pos, 
        const wxSize& size, 
        const long style);

    void InitToolBar(wxToolBar* toolBar);
    void OnSize(wxSizeEvent& event);
    void OnAbout(wxCommandEvent& event);
    void OnQuit(wxCommandEvent& event);
    void OnClose(wxCloseEvent& event);
    void OnNewIMSIWindow(wxCommandEvent& event);
    void OnGsmOpt(wxCommandEvent& event);
    void OnWelcomeMsgOpt(wxCommandEvent& event);
    void OnLangChgCh(wxCommandEvent& event);
    void OnLangChgEn(wxCommandEvent& event);
    void OnAct(wxActivateEvent& event);
private:
    void showIMSIFrame();
    int  m_only1IMSIFrame;
    
    DECLARE_EVENT_TABLE()
};

class IMSIChildFrame: public wxMDIChildFrame
{
public:
    IMSIChildFrame(wxMDIParentFrame *parent, const wxString& title);
    ~IMSIChildFrame();

    void OnActivate(wxActivateEvent& event);
    void OnRefresh(wxCommandEvent& event);
    void OnUpdateRefresh(wxUpdateUIEvent& event);
    void OnChangeTitle(wxCommandEvent& event);
    void OnChangePosition(wxCommandEvent& event);
    void OnChangeSize(wxCommandEvent& event);
    void OnQuit(wxCommandEvent& event);
    void OnSize(wxSizeEvent& event);
    void OnMove(wxMoveEvent& event);
    void OnClose(wxCloseEvent& event);
    void OnButton(wxCommandEvent& event);

#if wxUSE_CLIPBOARD
    void OnPaste(wxCommandEvent& event);
    void OnUpdatePaste(wxUpdateUIEvent& event);
#endif // wxUSE_CLIPBOARD
    void SetGrid(wxGrid *pGrid) {m_pGrid = pGrid;}
    void OnSelectCell(wxGridEvent&  event);
    void OnSelectRightCell(wxGridEvent& event);
    void OnSelectLeftCell(wxGridEvent& event);

    DECLARE_EVENT_TABLE()

private:
    wxGrid * m_pGrid;
    wxMenu * m_pGridPrivatePopupMenu;
    IMSITable * m_imsilist;
    SingleColDBI * m_callid;
    int m_grid_selx, m_grid_sely;
    bool m_bSelectedCell;
    void refreshIMSIList(); 
    void onSendSMS(wxCommandEvent& WXUNUSED(event));
};

//AdminDialog
class AdminDialog : public wxDialog
{
public:
    AdminDialog(wxWindow * parent);
    void OnButton(wxCommandEvent& evt);
    typedef enum {
        PWDOK,
        PWDERROR,
        INVALID
    }AdminCode;

private:
    wxButton * m_btnOK;
    wxButton * m_btnCancel;
    wxTextCtrl * m_pTxtPwd;
    bool     m_bSet;
    static const std::string KEY;

    DECLARE_EVENT_TABLE();
};

//ModalDialog
class GsmModalDialog : public wxDialog
{
public:
    GsmModalDialog(wxWindow *parent);
    void OnButton(wxCommandEvent& evt);

private:
    wxButton * m_btnOK;
    wxButton * m_btnCancel;
    wxButton * m_btnReboot;
    wxButton * m_btnApply;
    wxButton * m_btnMail;
    wxTextCtrl * m_spinMCC;
    wxTextCtrl * m_spinMNC;
    wxTextCtrl * m_spinLAC;
    wxTextCtrl * m_spinCellID;
    wxTextCtrl * m_spinNCC;
    wxTextCtrl * m_spinBCC;
    wxTextCtrl * m_spinArfcn;
    wxTextCtrl * m_spinNeighborCell;

    void update();
    void apply();
    void setMail();

    DECLARE_EVENT_TABLE();
};

class SendSMSModalDialog : public wxDialog
{
public:
    SendSMSModalDialog(wxWindow *parent, wxString imsi, wxString callid);
    void OnButton(wxCommandEvent& evt);
    
private:
    wxTextCtrl * m_pTxtSMSContent;
    wxTextCtrl * m_pTxtSrcAddr;
    wxString m_imsi;
    wxString m_callid;
    wxButton * m_btnSend;
    wxButton * m_btnCancel;
    
    DECLARE_EVENT_TABLE();
};

class WelcomeMsgModalDialog: public wxDialog
{
public:
    WelcomeMsgModalDialog(wxWindow *parent);
    void OnButton(wxCommandEvent& evt);
    
private:
    wxChoice * m_pMsgChoice;
    wxTextCtrl * m_pTxtMsgContent;
    wxButton * m_pBtnDel;
    wxButton * m_pBtnSetDefault;
    wxButton * m_pBtnAddNew;
    wxButton * m_pBtnCancel;
    void getData(wxArrayString& choices);
    
    DECLARE_EVENT_TABLE();
};

class AddingWelcomeMsgModalDialog: public wxDialog
{
public:
    AddingWelcomeMsgModalDialog(wxWindow *parent);
    void OnButton(wxCommandEvent& evt);
private:
    wxSpinCtrl *  m_pSpinAging;
    wxTextCtrl * m_pWelcomeMsgContent;
    wxButton * m_pBtnAdd;
    wxButton * m_pBtnCancel;
    
    DECLARE_EVENT_TABLE();
};

// menu items ids
enum
{
    MDI_QUIT = wxID_EXIT,
    MDI_ABOUT = wxID_ABOUT,
    MDI_NEW_WINDOW = wxID_HIGHEST,
    MDI_LANG,
    MDI_LANG_CHN,
    MDI_LANG_ENG,
    MDI_GSM_OPTS,
    MDI_WELCOMEMSG_OPTS,
    MDI_VIEW_IMSI,
    MDI_REFRESH,
    MDI_CHANGE_TITLE,
    MDI_CHANGE_POSITION,
    MDI_CHANGE_SIZE,
    MDI_CHILD_IMSI_REFRESH,
    MDI_CHILD_QUIT,
    MDI_CHILD_GRID,
    MDI_CHILD_BUT_REFRESH,
    MDI_CHILD_BUT_DEL,
    MDI_GRID_SEND_SMS,
    MDI_GRID_SEND_VOICE,
    MDI_GRID_RELEASE_MONITOR,
    MDI_GRID_MODIFY_INFO
};
